<?php
/**
 * Admin Filter
 * User: guo.hao
 * Date: 14-3-18
 * Time: am 9:51
 */
class IpFilter extends CFilter{
    private $allow_list = array("home/ipdeny","about/contactus","about/sendcontactusemail","about/information");
    protected function preFilter($filterChain){
        $ip = Yii::app()->tools->getIp();
        $deny_ip = Fun::getIpDenyList();
        $controller = strtolower(Yii::app()->controller->id);
        $action = strtolower(Yii::app()->controller->getAction()->getId());
        $route = $controller.'/'.$action;
        if(in_array($route,$this->allow_list))   return true;
        if(in_array($ip,$deny_ip)){
            $url = Yii::app()->controller->createUrl('home/ipdeny');
            Yii::app()->controller->redirect($url);
        }
        return true;
    }
    protected function postFilter($filterChain){}
}

